package com.pi.shisan.test.client.receiver;

import com.pi.shisan.test.client.start.StartListener;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class ReceiverDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) throws Exception {
        int i = in.readShort();
        int len = in.readShort();
        if (i == 2) {
            //TODO 连接成功
            StartListener startListener = new StartListener(ctx.channel());
            new Thread(()->{
                startListener.run();
            }).run();
        }
//        System.out.println("ok: "+i);
    }
}
